package com.learn.demo.controller;

import com.learn.demo.service.IDemoService;
import com.learn.mvcframework.annotations.MyAutowired;
import com.learn.mvcframework.annotations.MyController;
import com.learn.mvcframework.annotations.MyRequestMapping;
import com.learn.mvcframework.annotations.Security;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@MyController
@MyRequestMapping("/demo")
public class DemoController {


    @MyAutowired
    private IDemoService demoService;


    /**
     * URL: /demo/query?username=lisi
     *
     * @param request
     * @param response
     * @param username
     * @return
     */
    @MyRequestMapping("/query")
    public String query(HttpServletRequest request, HttpServletResponse response, String username) {
        return demoService.get(username);
    }

    /**
     * URL: /demo/handle?username=lisi
     *
     * @param request
     * @param response
     * @param username
     * @return
     */
    @Security
    @MyRequestMapping("/handle")
    public String handle(HttpServletRequest request, HttpServletResponse response, String username) {
        return "SUCCESS" + username;
    }
}
